(function(app){
	app
		.controller("charge_intimeCtrl",["$scope","$rootScope","$state","myFactory",'$http','$stateParams','$interval',"$q",'$timeout',"$ionicHistory",function($scope,$rootScope,$state,myFactory,$http,$stateParams,$interval,$q,$timeout,$ionicHistory){
			//参数接收、定义
			var chdrnum01=$stateParams.chdrnum01;
			var chdrcoy = $stateParams.chdrcoy;
			var intimeData = $stateParams.intimeData;
			var policyData;//保单详情
			var inputCode_temp = "";//缓存生成的校验码、初始化时生成一个
			var phoneCode_temp = "";//缓存生成的手机验证码
			var _checkFlag = false;	//	是否正在提交缴费标示
			var itemId = intimeData.itemId;
			var timeOut="N";
			var maxTime = 0;
			var token=sessionStorage.getItem("token");
		
			$scope.readFlag = false;//是否阅读了须知
			//绑定信息到页面
			$scope.chdrnum01= $stateParams.chdrnum01;
			$scope.intimeData = $stateParams.intimeData;
            /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
            $scope.policy = intimeData.policy; //获得缓存保单
            /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
			$scope.banks = intimeData.banks;
			$scope.textFlag = true;//默认可以点击获取手机验证码
			$scope.code="";//初始化校验码
			//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）start
            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 start
            var authorizedAmt = '999999999'; //授权总金额
            var paymentTimes = 0; //缴费次数
            var paymentDeadline = ''; //缴费截止日
            var limitPer; //每期扣款限额
            var maxMoney;
            var currentAmount; //单笔授权金额的最低限制
            //S2018122906735移动保全新增变更项目及功能的优化需求 add by yangyan 20201022 start
            var strItemIds;
            //S2018122906735移动保全新增变更项目及功能的优化需求 add by yangyan 20201022 end
            $scope.itemList = intimeData.itemList;
            for (var i = 0; i < $scope.itemList.length; i++) {
                //S2018122906735移动保全新增变更项目及功能的优化需求 add by yangyan 20201022 start
                //04(缴别变更)、17(额外投资)、23(复效)、33(结束缓缴期)、37(补缴保障费用和保单管理费)、38(保单还款)、
                //11(被保险人职业)、15(保险计划)、29(取消承保条件)、30(补充告知)
                var currentItemId = $scope.itemList[i].itemId;
                strItemIds += currentItemId + ",";
                if (currentItemId == '04' || currentItemId == '17' || currentItemId == '23' || currentItemId == '33' ||
                        currentItemId == '37' || currentItemId == '38' || currentItemId == '15' ||
                        currentItemId == '29' || currentItemId == '30') {
			//if(itemId=='04'||itemId=='17'||itemId=='23'||itemId=='33'||itemId=='37'||itemId=='38'){
                    //S2018122906735移动保全新增变更项目及功能的优化需求 add by yangyan 20201022 end
                    itemId = $scope.itemList[i].itemId;
                    isContain = true;
                    break;
			}
            }
            //S2018122906735移动保全新增变更项目及功能的优化需求 add by yangyan 20201022 start
            strItemIds = strItemIds.substr(0, strItemIds.length - 1);
            //S2018122906735移动保全新增变更项目及功能的优化需求 add by yangyan 20201022 end
            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 end
			$scope.Bankaccount = {
					counts:0
			}
			//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）end
			var payRequestTime=3;//查询支付接口次数限制
			var payRequestPerTime=10000;//每次调用间隔时间：10s
			
			
			/*********** 《S2019091010023 移动保全限制湖南分公司使用被保人账号进行保全缴费系统需求》  add by yangyan 20200317 start***********/	
			//湖南省保单通过移动保全办理“续期账户”变更，账户所有人默认显示投保人姓名，不显示被保险人
			$scope.hunanShowFlag = true;
			if(intimeData.hunan){
				$scope.hunanShowFlag = false;
			}
			/*********** 《S2019091010023 移动保全限制湖南分公司使用被保人账号进行保全缴费系统需求》   add by yangyan 20200317 end***********/
			
			$scope.data = {
				timeCon: '获取手机验证码',
				time1: null,
				//disabledFlag: true
				bankVal: null,
				code:null,
			};
			
			//重新受理
			$scope.renew = function(){
				$interval.cancel($scope.data.time1);//成功跳转关闭计时
				myFactory.renew();
			}
			//退出移动保全
			$scope.exit = function(){
				$interval.cancel($scope.data.time1);//成功跳转关闭计时
				myFactory.exit();
			}
			//返回上一步
			$scope.goBack = function () {
				$interval.cancel($scope.data.time1);//关闭计时
				myFactory.goBack();
			}
			//保单详情弹窗
			$scope.showPolicyDetail = function(){
				modal('open','policyDetailModelOnChargeIntime','overwindowOnChargeIntime','policyDetailCloseXOnChargeIntime');
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）start
				if (policyData != null ) return;
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）end
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//初始化时候查询保单详情
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;
						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
					}
				}, function errorCallback(response) {
					myFactory.alert("","初始化查询订单详情失败!","info");
				});
			}
			//保单详情弹窗关闭函数
			$scope.policyDetailCancelOnChargeIntime = function(){
				modal('close','policyDetailModelOnChargeIntime','overwindowOnChargeIntime','policyDetailCloseXOnChargeIntime');
			}
			//关闭遮罩
			$scope.overwindowClose = function(){
				//$(".overwindow").show();
				$(".overwindow").hide();
				$(".overmodal").hide();
			}
			
			//选择账号持有人
			$scope.changeClntnme = function(type){
				var clntnme = $("input[name='clntnme']:checked").val();//单项被选择的，要么等于1或者2
				$("#paynmeForIntime").val("");
				if(clntnme == type && type == 1){
					 $("#paynmeForIntime").val($("#surname").val());
					 $("#paynumForIntime").val($("#policyHolderClntNum").val());
					 $("#paynmeFlagForIntime").val('1');
				}else if(clntnme == type && type == 2){
					$("#paynmeForIntime").val($("#rnName").val());
					$("#paynumForIntime").val($("#insurantClntNum").val());
					$("#paynmeFlagForIntime").val('2');
					var a = $("#paynmeForIntime").val();
					var b = $("#paynumForIntime").val();
					var c = $("#paynmeFlagForIntime").val();
					
				}
				/*else if(clntnme == type && type == 3){
					 $("#paynme").val($("#beneName").val());
					 $("#paynmeFlag").val('3');
				}*/
			}
			
			
			
			//银行选择弹框（弹框式，不再使用）
//			$scope.bankChose = function(){
//				modal('open','bank_model','overwindowOnChargeIntime');
//			}
//			$scope.bankClose = function(){
//				modal('close','bank_model','overwindowOnChargeIntime');
//			}
//			$scope.bankClick = function (val) {
//				$scope.data.bankVal = val;
//			}
			//银行选择（下拉式，正在采用）
			$scope.bankChose = function(){
				var options =$("#bankSelect option:selected");
				var a = options.val();
				var b = options.text();
				console.log(a);
				console.log(b);
				$("#bankInput").val(b);
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）start
				//需要签约则给提示
				for (var i = 0 ;i < pclistBack.length ; i ++ ){
					if ( pclistBack[i].code == a ){
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 start
                        if ((pclistBack[i].limit != '' && pclistBack[i].limit > 0) && pclistBack[i].limit != '999999999' && a != '04') { //有限额
                            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 end
							$scope.Bankaccount.counts = pclistBack[i].limit;
							$('#showbankCause').show();
						} else{
							$('#showbankCause').hide();
						}
					}
					}
				if (isContain){
					sigleLimitAmount=options.attr('data1');//单日限额
			        dayLimitAmount=options.attr('data2');//日累计限额
			        monthLimitAmount=options.attr('data3');//月累计限额
			        dueDate=options.attr('data4');//委托日期
			        
					if(b.indexOf("签约")>=0 ){
						$('#showContractCase').show();
					}else {
						$('#showContractCase').hide();
					}
				}
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）end
			}
			
			//选择账户类型
			$scope.accountTypeChose = function(){
				var a = $("#accountTypeSelect option:selected").val();
				var b = $("#accountTypeSelect option:selected").text();
				console.log(a);
				console.log(b);
				$("#accountTypeInput").val(b);
			}
			
			/**
			 * 只输入整数函授
			 */
			$scope.keyNumPress = function(){
				var keyCode = event.keyCode;
				if(keyCode>=48 && keyCode<=57){
					event.returnValue = true;
				}else{
					event.returnValue = false;
				}
			}
			
			
			//图片验证码
			$scope.createCodeForIntime = function() {
				//移动保全应用系统安全开发检查表 add by huanghk 20230802 start
                /*code = "";
                var codeLength = 4; //验证码的长度
                var checkCode = document.getElementById("checkCodeForIntime");
                code = getInitCodeForIntime(); //获得图片验证码
                if (checkCode) {
                    checkCode.className = "code";
                    checkCode.innerHTML = code;
                }
                console.log(code); //得到验证码
                */
                getInitCodeForIntime();
                //移动保全应用系统安全开发检查表 add by huanghk 20230802 end
            }

            //获得图片验证码
            function getInitCodeForIntime() {
			   //移动保全应用系统安全开发检查表 add by huanghk 20230802 start
               /*var code = "";
                var codeLength = 4; //验证码的长度
                var codeChars = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
                    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
                    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); //所有候选组成验证码的字符，当然也可以用中文的
                for (var i = 0; i < codeLength; i++) {
                    var charNum = Math.floor(Math.random() * 52);
                    code += codeChars[charNum];
                }
                inputCode_temp = code; //将生成验证码存于缓存中
                return code;*/
                var checkCode = document.getElementById("checkCodeForIntime");
                var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'post',
					url: app.domain + "common/captchaImage.action",
					data:{'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						$scope.uuid = response.data.data.uuid;
						var img = response.data.data.img;
						//code = response.data.data.code;
						if (checkCode){
							//checkCode.className = "code";
							//checkCode.innerHTML = code;
							//$scope.code= code;
							checkCode.src="data:image/jpg;base64,"+img;
						}
						//console.log(code);
					}else{
						myFactory.alert('','获取图片验证码失败！','info');
					}
				}, function errorCallback(response) {
					myFactory.alert('','获取图片验证码失败！','info');
				});
				//移动保全应用系统安全开发检查表 add by huanghk 20230802 end
            }
			//图片验证码校验方法
			$scope.validateCodeForIntime = function(){
				var flag=false;
				var inputCode = $("#inputCode").val();
				if (inputCode.length <= 0){
					myFactory.alert('','请输入图片验证码！','info');
					$("#inputCode").focus();
					return flag;
				} else if (inputCode.length < 4) {
					myFactory.alert('','输入图片验证码有误，请重新输入！','info');
					$("#inputCode").focus();
					return flag;
                //移动保全应用系统安全开发检查表 add by huanghk 20230802 start
                /*} else if (inputCode.toUpperCase() != inputCode_temp.toUpperCase()) {
                    myFactory.alert('', '输入图片验证码有误，请重新输入！', 'info');
                    $("#inputCode").focus();
                    return flag;*/
                //移动保全应用系统安全开发检查表 add by huanghk 20230802 end
				} else {
					flag=true;
				}
				return flag;
			}
			
			
			//获得验证码
			$scope.getValidateNumForIntime = function(){
//				var telNo = $("#telNo").val();
				var telNo = intimeData.telNo;
				var inputCode = $("#inputCode").val();//得到图片验证码
				
				if(!telNo){
					myFactory.alert('','手机号码为空！请先办理通讯方式变更','info');
					return false;
				}

				//进行图片代码校验
				var validateCode=$scope.validateCodeForIntime();
				if(!validateCode){
					return false;
				}
				//移动保全应用系统安全开发检查表 add by huanghk 20230802 start
				var uuid = $scope.uuid;
                var url = "common/getChargeValidateNum.action";
                myFactory.loadingShow(); //显示加载圈
                var timestamp = myFactory.getTimetamp();
                var sfis = "telNo-amnt-valfrom-valnum-token-timestamp";
                var signStr = "telNo=" + telNo + "&amnt=" + intimeData.charge.receiptAmount + "&valfrom=" + uuid + "&valnum=" + inputCode + "&token=" + token + "&timestamp=" + timestamp; //encodeURI(name)
                var sign = myFactory.hex(signStr);
                $http({
                    method: 'GET',
                    url: app.domain + url,
                    //					{"telNo":telNo,"amnt":'${charge.receiptAmount }', "valfrom":"secondValNum", "valnum":valnum}
                    params: { "telNo": telNo, "amnt": intimeData.charge.receiptAmount, "valfrom": uuid, "valnum": inputCode, 'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp }
                }).then(function successCallback(response) {
                    if (response.data.success) {
                        var sendStatus = response.data.data.sendStatus;
                        var codeTemp = response.data.data.code;
                        //console.log("返回手机验证码:"+codeTemp);
                        myFactory.loadingHide();
                        if(codeTemp=='000000'){
							myFactory.alert('','输入图片验证码有误，请重新输入！','info');
						}else{
							$scope.startItervalForIntime();
	                        phoneCode_temp = codeTemp; //将验证码放于缓存中
	                        if (sendStatus == '-2') {
	                            myFactory.alert('', '获取手机验证码发送异常！', 'info');
	                        }
	                        if (sendStatus == '3') {
	                            myFactory.alert('', '获取手机验证码太频繁,请稍候再试！', 'info');
	                        }
	                        if (sendStatus == '10') {
	                            myFactory.alert('', '获取手机验证码超过每小时限制次数,请稍后重试！', 'info');
	                        }
						}
                    }
                    /*else{
                    						myFactory.alert('','服务器繁忙，请稍后再试！','info');
                    						myFactory.loadingHide();
                    					}*/
                }, function errorCallback(response) {
                    myFactory.alert('', '访问后台失败，请稍后再试！', 'info');
                    myFactory.loadingHide();
                });
                //移动保全应用系统安全开发检查表 add by huanghk 20230802 end
			}
			
			
			//手机验证码倒计时180秒
			$scope.startItervalForIntime = function(){
				maxTime=180;//10;//180
				timeOut="N";
				$scope.textFlag = false;//让获得验证码按键失效
				$scope.data.timeCon = "有效期："+maxTime+"S";
				$scope.data.time1 = $interval(function(){
					//console.log("rest time1:"+maxTime);
					$("#ipttimeForIntime").val(maxTime);//将当前时间存下来
					maxTime--;
					//console.log("rest time2:"+maxTime);

					if (maxTime < 1) {//当时间倒数到0时候，变成可以重新获取手机验证码，同时关了倒计时
						$scope.data.timeCon = "获取手机验证码";
						$scope.textFlag = true;
						$interval.cancel($scope.data.time1);
					} else {
						$scope.data.timeCon = "有效期："+maxTime+"S";
					}

					if(maxTime==0){
						timeOut="Y";
						//myFactory.alert('','手机验证码已过期！请重新获取验证码','info');
						$("#ipttimeForIntime").val(maxTime);
						//$scope.changeImg('valnumPic');//优化一下，过期不刷新，免得客户觉得又要多一次输入验证码
						//$("#valnum").val("");
						//stopIterval(timer);
						return false;
					}
		        }, 1000);
			}
			
/*****************************************************页面初始化部分start********************************************************/
			//先初始化一个图片校验码
            //移动保全应用系统安全开发检查表 add by huanghk 20230802 start
            //var initCode = getInitCodeForIntime();
            //$scope.code = initCode;
            getInitCodeForIntime();
            //移动保全应用系统安全开发检查表 add by huanghk 20230802 end
			
			//初始化默认选投保人
			$scope.changeClntnme('1');
			
			//初始银行默认为第一个
//			$("#bankSelect option:eq(4)").attr("selected","selected");
//			$("#bankSelect option:nth-child(4)").attr("selected","selected");
			//去除初始化银行选择 20180212 进入实时缴费界面，缴费银行默认建设银行，修改为空值，让客户选取
			/*$scope.bankSelect = '04';
			$("#bankSelect").val('04');
			$("#bankInput").val("中国建设银行");*/
			
			
			
/*****************************************************页面初始化部分end********************************************************/
			/**
			 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）
			 * 新增签约接口的逻辑 add by csf 20180926 start
			 */
			    var accountNo='';//账号
	            var accountName;//户名
	            var accountType ='00';//银行卡类型，默认为银行卡
	            var bankCode ;//银行编号
	            var bankNames ;//银行名称
	            var phoneNum ;//手机号
	            var code ;//验证码
	            var signMode;//签约类型
	            var idType ;//身份类型
	            var id ;//身份证号
	            var vailddate;//信用卡有效期
	            var cvv2 ;//信用卡cvv2
	            var isContract = true;//是否签约了,刚进入默认为已经签约了
	            var agreePayCompanyCode ='';
	            var sigleLimitAmount="";//单日限额
	            var dayLimitAmount="";//日累计限额
	            var monthLimitAmount="";//月累计限额
	            var dueDate="";//委托日期
	            var isContain; //是否包含在需要签约的变更项中
	            var bankinfomations=[];//缓存中存在的银行信息
	            var pclistBack=[];//已经添加了签约信息的银行列表
	    		var  cntbranch;//
	    		//S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求) by  CYQ  20190910 start
	    		var idTypeName;//证件类型名称
	    		//S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求) by  CYQ  20190910 end
	        	$scope.idTypeLF=[
	                {contractVal:'0',pasVal:'1',text:'身份证'},
	                {contractVal:'1',pasVal:'7',text:'户口簿'},
	                {contractVal:'2',pasVal:'2',text:'护照'},
	                {contractVal:'3',pasVal:'3',text:'军官证'},
	                {contractVal:'4',pasVal:'8',text:'士兵证'},
	                {contractVal:'7',pasVal:'6',text:'出生证/临时身份证'},
	                {contractVal:'5',pasVal:'4',text:'港澳居民来往内地通行证'},
	                {contractVal:'6',pasVal:'9',text:'台湾同胞来往内地通行证'},
//	                {value:'6',text:'出生证'},
	                {contractVal:'8',pasVal:'A',text:'外国人居留证'},
	                {contractVal:'5',pasVal:'B',text:'港澳居民居住证'},
	                {contractVal:'6',pasVal:'C',text:'台湾居民居住证'},
	                {contractVal:'x',pasVal:'5',text:'其他证件'}
	            ];
	            /**
				 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）
				 * 新增签约接口的逻辑 add by csf 20180926 end
				 */
			
			//下一步
			$scope.nextStep = function(){
				//myFactory.loadingShow();//显示加载圈
				myFactory.loadingHide();
				//新增实时收付费客户须知 add by csf 2019-1-3 start
				//如果没有同意协议，不给下一步
				if($scope.readFlag == false){
					myFactory.alert("","请阅读并同意变更费用自动转账付款授权客户须知。","info");
					_checkFlag = false;
					return;
				}
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf start
				//需要签约
				if(isContain){
					bankCode = $("#bankSelect option:selected").val().trim();//选定的银行编号			
						if (!isContract){//未签约
							_checkFlag = false;
						$timeout(function(){
							modal('open','contract_model_info','overwindowOnChargeRefund');
						},500);
						return;
						}
				}
			  	//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf end
				//新增实时收付费客户须知 add by csf 2019-1-3 end
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf start
				if(_checkFlag==false || $rootScope['payFail'] ){
				//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf end
					console.log("正常提交支付："+_checkFlag);
					_checkFlag = true;
	            }else{
		    //S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf start
	            	   if ( !$rootScope['isCon'+accountNo+itemId] ){
			   //S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by end 
	            			console.log("重复提交支付，禁止执行："+_checkFlag);
	    	                return false;
	            	   }
	            }
				
				//如果状态为[true-正在缴费]时，提示且返回false
				/*if(_checkFlag){
					myFactory.alert('','正在进行缴费，请勿重复操作！','info');
					return false;
				}*/
				
				//对输入的银行账户进行校验
				var bankacctkey = $("#bankacctkeyForIntime").val();
				bankacctkey = bankacctkey.replace(/\s+/g, "");
				if(bankacctkey == ""){
					myFactory.alert('','请输入银行账号','info');
					//myFactory.loadingHide();
					_checkFlag = false;
					return false;
				}else{
					var item;
		        	var flag=false;
		        	for(var i=0;i<bankacctkey.length;i++){
		        		item=bankacctkey.charAt(i);    
		        		if(isNaN(item)){//item为非数字
		        			flag=true;
		        		}	
		        	}
		        	if(flag==true){
		        		myFactory.alert("","银行账号/卡号请输入数字！","info");
		        		//myFactory.loadingHide();
		        		_checkFlag = false;
		        		return;
		        	}
				}			
				
				var bankSelect=$("#bankSelect").val();
				if(bankSelect == null || bankSelect.trim() == "" || bankSelect == undefined){
					myFactory.alert("","请选择开户银行","info");
					//myFactory.loadingHide();
					_checkFlag = false;
					return;
				}
				
				//进行图片代码校验
				var validateCode=$scope.validateCodeForIntime();
				if(!validateCode){
					//myFactory.loadingHide();
					_checkFlag = false;
					return false;
				}
				//检验是否输入了手机验证码
				var phoneCode = $("#phoneCode").val();
				if(phoneCode == ""){
					myFactory.alert('','请输入手机验证码','info');
					//myFactory.loadingHide();
					_checkFlag = false;
					return false;
				}
				var codePay=myFactory.hex(phoneCode);
				if(codePay != phoneCode_temp){
					myFactory.alert('','手机验证码输入错误','info');
					//myFactory.loadingHide();
					_checkFlag = false;
					return false;
				}
				//如果超出时间则弹出提示
				if(maxTime==0 || timeOut=="Y"){
					if(timeOut=="Y"){
						myFactory.alert('','手机验证码已过期！请重新获取验证码','info');
						//myFactory.loadingHide();
						_checkFlag = false;
						return false;
					}else{
						myFactory.alert('','请先获取验证码','info');
						//myFactory.loadingHide();
						_checkFlag = false;
						return false;
					}
				}
                /*S2023011824901-官微授权银行页面超限额无拦截、非签约银行进入签约页面问题 add by huanghk 20230216 start*/
                if(Number($scope.Bankaccount.counts)>0 && Number($scope.Bankaccount.counts)<Number(intimeData.charge.receiptAmount)){
                	 myFactory.alert("","缴费金额超出银行转账限额，请您选择其它银行账户","info");
                	 myFactory.loadingHide();
                	 _checkFlag = false;
                     return;
                }
                /*S2023011824901-官微授权银行页面超限额无拦截、非签约银行进入签约页面问题 add by huanghk 20230216 end*/
				
				//不再引入第二次校验框
//				var bankacctkeyCon = $("#bankacctkeyConForIntime").val();
//				if(bankacctkeyCon == ""){
//					myFactory.alert('','请再次输入账号','info');
//					return false;
//				}else{
//					var item;
//			    	var flag=false;
//			    	for(var i=0;i<bankacctkeyCon.length;i++){
//			    		item=bankacctkeyCon.charAt(i);    
//			    		if(isNaN(item)){//item为非数字
//			    			flag=true;
//			    		}	
//			    	}
//			    	if(flag==true){
//			    		myFactory.alert('','银行账号/卡号请输入数字！','info');
//			    		return false;
//			    	}
//				}
//				if(bankacctkey != bankacctkeyCon){
//					$("#bankacctkeyCon").testRemind("账号不一致。");
//					return false;
//				}
				
//				if(jQuery("#code").val()!=jQuery("#vlData").val()){
//					$("#code").testRemind("手机验证码输入错误!");
//					return false;
//				}
//				if(!jQuery("#code").val()){
//					$("#code").testRemind("请输入手机验证码!");
//					return false;
//				}
				
				
				//	设置状态为[正在缴费]，防止正在缴费时候又提交了一次
				//_checkFlag = true;
				
				/**********************************************计时器结束处理begin**********************************************/
		 		//提交后台之前，首先停止倒计时，并且还原成可以重新获取验证码状态
				$scope.data.timeCon = "获取手机验证码";
				$scope.textFlag = true;
				$interval.cancel($scope.data.time1);//立即终止倒计时,避免出现滚动条转动的时候已经到时间临界点
				timeOut="Y";//手动让当前验证码超时，让用户重新获取一次验证码
				/**********************************************计时器结束处理end**********************************************/
				/**
				 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）
				 * 新增签约接口的逻辑 add by csf 20180926 start
				 */
				accountNo = bankacctkey;
				accountName = $("#paynmeForIntime").val().trim();
				bankNames = $("#bankSelect option:selected").text().trim();
				id = policyData.secuityno; //证件号码
				id = id.trim();
				if($("input[name='clntnme']:checked").val() =="1"){
					idType = policyData.roleflag35; //证件类型
				}else{
					idType = policyData.rnrolefag35; //证件类型
				}
				 for(var i=0 ; i<$scope.idTypeLF.length ; i++){
	                    if( $scope.idTypeLF[i].pasVal=== idType ){
	                    	idType = $scope.idTypeLF[i].contractVal;//证件类型
	                    	//S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求) by  CYQ  20190910 start
	                    	idTypeName = $scope.idTypeLF[i].text;//证件类型名称
	                    	//S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求) by  CYQ  20190910 end
	                    	break;
	                    }
	                }
				idType = idType.trim();
				phoneNum = policyData.mobilphone;
				code ='';//验证码
				signMode = '02';//请求类型
				vailddate = '';//信用卡的有效期
             	cvv2 = '';//信用卡的CVV2编号
             	
                //判断全局变量，是否已经签约完成了，是的话，不检查下面的，直接进行接下来的 add by csf 20180926
             	if ( $rootScope['isCon'+accountNo+itemId] ){
                	nextOnStep(bankacctkey);
                    return;
                }
             	//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf start
             	//增加判断是否是需要签约的变更项
             	if ( isContain ){
             		//查询是否需要签约
             		   myFactory.goBankContract(bankSuccess,bankError);
             	}else {
             		nextOnStep(bankacctkey);
             	}
             	//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）add by csf end
			}	
			
			function nextOnStep(bankacctkey){
				/**
    			 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）
    			 * 新增签约接口的逻辑 add by csf 20180926 end
    			 */
				//数据包装
				var pageData2 = {
//						"accountFlag":$("#accountFlag").val().trim(),
						"accountType":$("#accountTypeSelect option:selected").val().trim(),
						"bankacctkey":bankacctkey,
//						"bankacctkey1":$("#bankacctkey1").val().trim(),
//						"bankacctkey3":$("#bankacctkey3").val().trim(),
						"bankacctkeyCon":bankacctkey,
						"bankcode":$("#bankSelect option:selected").val().trim(),
//						"bankcode1":$("#bankcode1").val().trim(),
//						"bankcode3":$("#bankcode3").val().trim(),
//						"bankdesc":$("#newBankSelect option:selected").text().trim(),
//						"bankdesc1":$("#bankdesc1").val().trim(),
//						"bankdesc3":$("#bankdesc3").val().trim(),
//						"beneClntNum":beneClntNum,
						"chargeType":"1",
						//"city":"5810",//页面上隐藏了选择城市部分，然后采用默认的广州（代码5810）
						"city":"",//页面上隐藏了选择城市部分，然后采用默认的广州（代码5810）
//						"city1":$("#city1").val().trim(),
//						"city3":$("#city3").val().trim(),
//						"citydesc":$("#newCity").val().trim(),
//						"citydesc1":$("#citydesc1").val().trim(),
//						"citydesc3":$("#citydesc3").val().trim(),
//						"itemIds":itemIds,
						"paynme":$("#paynmeForIntime").val().trim(),
//						"paynme1":$("#paynme1").val().trim(),
//						"paynme3":$("#paynme3").val().trim(),
						"paynmeFlag":$("#paynmeFlagForIntime").val().trim(),
//						"paynum":$("#paynum").val().trim(),
//						"paynum1":$("#paynum1").val().trim(),
//						"paynum3":$("#paynum3").val().trim(),
						"receiptAmount":intimeData.charge.receiptAmount,
//						"type":Type
                    //S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 start
                    "mobile":intimeData.telNo,
                    //S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 end
				}
				
				var timestamp=myFactory.getTimetamp();
				var sfis= "itemId-token-timestamp";
				var signStr="itemId="+itemId+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				
				//myFactory.loadingShow();
				//访问charge/restSave.action
				$("#intimePayId").show();
				$("#load_icon1").show();//转动
				$("#load_icon2").hide();//暂停
				$("#time_text").text("正等待对方银行返回结果...");
				
				$http({
					method: 'GET',
					url: app.domain + 'charge/restSave.action',
					params: {'itemId': itemId,'chargeStr': pageData2,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						var DataSave = response.data.data.pageData;
						var nextStep= DataSave.nextStep;//"charge/restInit.action";
						var message = DataSave.message;//用于检测实时缴费是否成功
						var reqSn = DataSave.reqSn;//支付流水号
						
						//对缴费情况进行判断，如果失败，则提示相关内容，不再进行下一步操作
						if(message == "" || message == 'fail'){
							//myFactory.alert('','本次转账失败，请选择其他缴费方式','info');
							_checkFlag = false;
							$("#load_icon1").hide();//转动
							$("#load_icon2").show();//暂停
							$("#time_text").text("本次转账失败，请选择其他缴费方式");
							$.alert({title: '',text: '本次转账失败，请选择其他缴费方式',onOK: function () {
								    $("#intimePayId").hide();
								    $("#inputCode").val("");//清空已经输入的验证码
								    $scope.createCodeForIntime();//重新更新一次验证码
								    $("#phoneCode").val("");//清空已经输入的手机验证码
							     }
							});
							return false;
						}else if(message != "" && message == 'handle'){//处理中
							//用延时控制比倒计时效果更好
							var times=1;//等待15s后再调用
							setTimeout(function() {
								intimePayQuery(itemId,message,nextStep,pageData2,reqSn,times);//供给成功后使用参数itemId,message,nextStep
							}, payRequestPerTime);
						}else if(message != "" && message == 'timeout'){
							_checkFlag = false;
							$("#load_icon1").hide();//转动
							$("#load_icon2").show();//暂停
							//$("#time_text").text("扣费处理中，请稍候，在结果返回前请勿关闭应用");
							$("#time_text").text("接收方银行返回结果超时，请稍后再提交申请或通过受理台提交纸质申请，在结果返回前，请不要重复支付");
							$.alert({title: '',text: '<div align="left" >接收方银行返回结果超时，请稍后提交申请或通过受理台提交纸质申请， <br /><span style=\'color:#e60012;font-size:15px;\'>在结果返回前，请不要重复支付</span></div>',onOK: function () {
									$ionicHistory.clearCache().then(function(){
										$state.go('search',{
											index:'yes'
										});
									})
							     }
							});
							return false;
						}else if(message != "" && message == 'clntnumnull'){
							//myFactory.alert('','支付失败！在线支付，获取的客户号为空，请重新支付','info');
							_checkFlag = false;
							$("#load_icon1").hide();//转动
							$("#load_icon2").show();//暂停
							$("#time_text").text("支付失败！在线支付，获取的客户号为空，请重新支付");
							$.alert({title: '',text: '支付失败！在线支付，获取的客户号为空，请重新支付',onOK: function () {
								    $("#intimePayId").hide();
								    $("#inputCode").val("");//清空已经输入的验证码
								    $scope.createCodeForIntime();//重新更新一次验证码
								    $("#phoneCode").val("");//清空已经输入的手机验证码
							     }
							});
							return false;
						}else if(message != "" && message == 'success'){ //成功时候才进行下一步操作
							console.log("首次调用统一收付费平台-实时缴费返回结果："+message+"将进入intimePaySuccess()处理成功后调整逻辑");
							intimePaySuccess(itemId,message,nextStep);
							/*sfis= "itemId-message-token-timestamp";
							signStr="itemId="+itemId+"&message="+message+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
							sign = myFactory.hex(signStr);
							//提交后台保存后，再次跳转到restInit.action，这次附带上检测标志的message
							$http({
								method: 'GET',
								url: app.domain + nextStep,
								params: {"itemId": itemId,"message":message,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
							}).then(function successCallback(response) {
								if (response.data.success) {
									var Data = response.data.data.pageData;
									var charge = Data.charge;
									var intime = Data.intime;
									var message = Data.message;
									var type = charge.type;
									_checkFlag = false;
									//以下这段逻辑跟check_mainCtrl中相似，一般来说，这里返回回来一定会得到message的结果，然后直接跳签名
									if(message!=undefined && message!=null && message!="" && message=="success" ){
										sfis= "itemId-token-timestamp";
										signStr="itemId="+itemId+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
										sign = myFactory.hex(signStr);
										//如果是success这种情况，表示保存成功，这里直接跳转签名
										//签名留影
										$http({
											method: 'GET',
											url: app.domain + "img/gotoSignMain.action",
											params: {"itemId": itemId,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
										}).then(function successCallback(response) {
											if (response.data.success) {
												var signMainData = response.data.data.signMainData;
												if(signMainData!=undefined && signMainData!=null && signMainData!=""){
													//$interval.cancel($scope.data.time1);//成功跳转关闭计时    变动：统一在前面操作关闭计时防止临界情况   BY ZZQ
													myFactory.loadingHide();
													$ionicHistory.clearCache().then(function(){
														$state.go('photo_sign',{
															itemId:itemId,
															chdrnum01:chdrnum01,
															chdrcoy:chdrcoy,
															signMainData:signMainData
														});
													});
												}
											}else{
												myFactory.alert("","后台繁忙，请返回重新尝试!","info");
												myFactory.loadingHide();
												_checkFlag = false;
											}
											myFactory.loadingHide();
										}, function errorCallback(response) {
											myFactory.alert("","访问后台出错，请稍后再试!","info");
											myFactory.loadingHide();
											_checkFlag = false;
										});
									}
									
								}else{
									myFactory.alert("","后台繁忙，请返回重新尝试!","info");
									myFactory.loadingHide();
									_checkFlag = false;
								}
								myFactory.loadingHide();
							}, function errorCallback(response) {
								myFactory.alert("","数据提交后台失败，请返回重新尝试!","info");
								myFactory.loadingHide();
								_checkFlag = false;
							});*/
						}
					}else{
					    _checkFlag = false;
						$("#load_icon1").hide();//转动
						$("#load_icon2").show();//暂停
						$("#time_text").text("本次转账失败，请选择其他缴费方式.");
						$.alert({title: '',text: '本次转账失败，请选择其他缴费方式',onOK: function () {
							    $("#intimePayId").hide();
							    $("#inputCode").val("");//清空已经输入的验证码
							    $scope.createCodeForIntime();//重新更新一次验证码
							    $("#phoneCode").val("");//清空已经输入的手机验证码
						     }
						});
						return false;
					}
				}, function errorCallback(response) {
				    _checkFlag = false;
					$("#load_icon1").hide();//转动
					$("#load_icon2").show();//暂停
					$("#time_text").text("本次转账失败，请选择其他缴费方式。");
					$.alert({title: '',text: '本次转账失败，请选择其他缴费方式。',onOK: function () {
						    $("#intimePayId").hide();
						    $("#inputCode").val("");//清空已经输入的验证码
						    $scope.createCodeForIntime();//重新更新一次验证码
						    $("#phoneCode").val("");//清空已经输入的手机验证码
					     }
					});
					return false;
				});
			}	
			
			function intimePayQuery(itemId,message,nextStep,chargeData,reqSn,times){
				console.log("开始调用支付查询接口 begin................第："+times+"次");
				$("#time_text").html("接收对方银行返回结果有延时，尝试第<span style='color:#e60012;font-size:18px;'>"+times+"</span>次再查询");
				
				var timestamp=myFactory.getTimetamp();
				var sfis= "reqSn-token-timestamp";
				var signStr="reqSn="+reqSn+"&token="+token+"&timestamp="+timestamp;//encodeURI(tbrName)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'GET',
					url: app.domain + 'charge/payQuery.action',
					params: {'chargeStr': chargeData,'reqSn':reqSn,'queryTimes':times,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						var message = response.data.data.message;
						console.log("调用支付查询接口payQuery.action获取查询结果:"+message);
						
						//成功，结束一切操作，跳转地址
						if(message != "" && message == 'success'){
							console.log("首次调用统一收付费平台-实时缴费返回结果："+message+"将进入intimePaySuccess()处理成功后调整逻辑");
							intimePaySuccess(itemId,message,nextStep);
						}else if(message != "" && message == 'handle'){
							console.log("支付成功还是处理中.....当前执行支付查询次数："+times);
							if(times<payRequestTime){
								times++;
								setTimeout(function() {
									intimePayQuery(itemId,message,nextStep,chargeData,reqSn,times);//供给成功后使用参数itemId,message,nextStep
								}, payRequestPerTime);
							}else{
								console.log("查询支付接口超过次数限制:"+times);
								console.log("payRequestTime次都是一样的支付状态，即将插入新表数据.....");
								$("#load_icon1").hide();//转动
								$("#load_icon2").show();//暂停
								$("#time_text").text("接收方银行返回结果超时，请稍后再提交申请或通过受理台提交纸质申请，在结果返回前，请不要重复支付。");
								$.alert({title: '',text: '<div align="left" >接收方银行返回结果超时，请稍后提交申请或通过受理台提交纸质申请， <br /><span style=\'color:#e60012;font-size:15px;\'>在结果返回前，请不要重复支付。</span></div>',onOK: function () {
										$ionicHistory.clearCache().then(function(){
											$state.go('search',{
												index:'yes'
											});
										})
								     }
								});
								return false;
							}
						}else if(message == "" || message == 'fail'){
							_checkFlag = false;
							$("#load_icon1").hide();//转动
							$("#load_icon2").show();//暂停
							$("#time_text").text("本次转账失败，请选择其他缴费方式");
							$.alert({title: '',text: '本次转账失败，请选择其他缴费方式',onOK: function () {
								    $("#intimePayId").hide();
								    $("#inputCode").val("");//清空已经输入的验证码
								    $scope.createCodeForIntime();//重新更新一次验证码
								    $("#phoneCode").val("");//清空已经输入的手机验证码
							     }
							});
							return false;
						}else{
							_checkFlag = false;
							$("#load_icon1").hide();//转动
							$("#load_icon2").show();//暂停
							$("#time_text").text("本次转账失败，请选择其他缴费方式.");
							$.alert({title: '',text: '本次转账失败，请选择其他缴费方式.',onOK: function () {
								    $("#intimePayId").hide();
								    $("#inputCode").val("");//清空已经输入的验证码
								    $scope.createCodeForIntime();//重新更新一次验证码
								    $("#phoneCode").val("");//清空已经输入的手机验证码
							     }
							});
							return false;
						}
					}
				}, function errorCallback(response) {
					 _checkFlag = false;
					 $("#load_icon1").hide();//转动
					 $("#load_icon2").show();//暂停
					 $("#time_text").text("本次转账失败,请选择其他缴费方式。");
					 $.alert({title: '',text: '本次转账失败,请选择其他缴费方式。',onOK: function () {
						 $("#intimePayId").hide();
						 $("#inputCode").val("");//清空已经输入的验证码
						 $scope.createCodeForIntime();//重新更新一次验证码
						 $("#phoneCode").val("");//清空已经输入的手机验证码
					 }
					 });
					 return false;
				});
			}
			
			function intimePaySuccess(itemId,message,nextStep){
				$("#time_text").text("支付成功");
				console.log("支付成功.....停留2秒跳转签名页面");//跳转指定界面
				setTimeout(function() {
					var timestamp=myFactory.getTimetamp();
					var sfis= "itemId-message-token-timestamp";
					var signStr="itemId="+itemId+"&message="+message+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
					var sign = myFactory.hex(signStr);
					//提交后台保存后，再次跳转到restInit.action，这次附带上检测标志的message
					$http({
						method: 'GET',
						url: app.domain + nextStep,
						params: {"itemId": itemId,"message":message,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
					}).then(function successCallback(response) {
						if (response.data.success) {
							var Data = response.data.data.pageData;
							var charge = Data.charge;
							var intime = Data.intime;
							var messageMsg = Data.message;
							var type = charge.type;
							_checkFlag = false;
							//逻辑同check_mainCtrl,返回获取message结果，跳转签名
							if(messageMsg!=undefined && messageMsg!=null && messageMsg!="" && messageMsg=="success" ){
								sfis= "itemId-token-timestamp";
								signStr="itemId="+itemId+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
								sign = myFactory.hex(signStr);
								//如果是success这种情况，表示保存成功，直接跳转签名
								//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
							
								var bankCardItems = {
											bankAccNum:$("#bankacctkeyForIntime").val()
								}
								if($scope.bankCardNum == $("#bankacctkeyForIntime").val()){
									bankCardItems['bigPic'] = $scope.bigPic;
								}
									 var timestamp = myFactory.getTimetamp();
					                 var sfis = "token-timestamp";
					                 var signStr = "token=" + token + "&timestamp=" + timestamp;//encodeURI(name)
					                 var sign = myFactory.hex(signStr);
									$http({
										method: 'POST',
										url: app.domain + 'img/saveBankCardCache.action',
										data:{paramsMap:bankCardItems,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
									}).then(function successCallback(response) {
										if (response.data.success) {
											console.log("saveBankCardCache ok");
										}
									}, function errorCallback(response) {
										console.log("saveIdCardCache error");
									});
									
								//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
								//签名留影
								$http({
									method: 'GET',
									url: app.domain + "img/gotoSignMain.action",
									params: {"itemId": itemId,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
								}).then(function successCallback(response) {
									if (response.data.success) {
										var signMainData = response.data.data.signMainData;
										if(signMainData!=undefined && signMainData!=null && signMainData!=""){
											$ionicHistory.clearCache().then(function(){
												$state.go('photo_sign',{
													itemId:itemId,
													chdrnum01:chdrnum01,
													chdrcoy:chdrcoy,
													signMainData:signMainData
												});
											});
										}
									}else{
										myFactory.alert("","后台繁忙，请返回重新尝试!","info");
										_checkFlag = false;
									}
									myFactory.loadingHide();
								}, function errorCallback(response) {
									myFactory.alert("","访问后台出错，请稍后再试!","info");
									_checkFlag = false;
								});
							}
						}else{
							//myFactory.alert("","后台繁忙，请返回重新尝试!","info");
							_checkFlag = false;
							 $("#load_icon1").hide();//转动
							 $("#load_icon2").show();//暂停
							 $("#time_text").text("本次转账失败，请选择其他缴费方式。");
							 $.alert({title: '',text: '本次转账失败，请选择其他缴费方式。',onOK: function () {
								 $("#intimePayId").hide();
								 $("#inputCode").val("");//清空已经输入的验证码
								 $scope.createCodeForIntime();//重新更新一次验证码
								 $("#phoneCode").val("");//清空已经输入的手机验证码
							 }
							 });
						}
					}, function errorCallback(response) {
						myFactory.alert("","数据提交后台失败，请返回重新尝试!","info");
						_checkFlag = false;
					});
				}, 2000);
			}
			
			/**
			 * 扫描银行卡信息
			 */
			$scope.scanBankCardInfoChargeIntime = function () {
				//移动端
				cordova.sino.getBankCardInfo(function(result){
					if(result.success){
						if(!result.data.exit){
							if(appVersion==="IOS"){
								if(result.data.ok){
									/*********************************待开发逻辑代码区域begin**********************************/
									var cardNumber=result.data.CardNumber;//卡号
									var cardInsName=result.data.CardInsName;//领取银行
									var bankCardType=result.data.BankCardType;//银行卡类型
									//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
									if ( bankCardType.indexOf('贷')>=0 ){
										myFactory.alert("","信用卡账户不允许授权，请选择储蓄卡","info");
										return;
									}
									//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
									//alert(CardNumber+","+CardInsName+","+BankCardType);
									cardNumber = cardNumber.replace(/ /g,"");
									//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
									$scope.bankCardNum = cardNumber;
									$scope.bigPic = result.data.bigPic;
									//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
									$("#bankacctkeyForIntime").val(cardNumber);
									//自动填充开户银行
									var flag = false;
									for(var i=0 ; i<$scope.banks.length ; i++){
										if($scope.banks[i].name.indexOf(cardInsName)>=0){
											$scope.bankSelect = $scope.banks[i].code;
											$("#bankSelect").val($scope.banks[i].code);
											$("#bankInput").val($scope.banks[i].name);
											/**
											 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 start
											 */
											showDialog2($scope.banks[i].code);
											if (isContain){
												showDialog($scope.banks[i].name)
											}
											sigleLimitAmount=$scope.banks[i].sigleLimitAmount;//单日限额
									        dayLimitAmount=$scope.banks[i].dayLimitAmount;//日累计限额
									        monthLimitAmount=$scope.banks[i].monthLimitAmount;//月累计限额
									        dueDate=$scope.banks[i].dueDate;//委托日期
											/**
											 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 end
											 */
											flag = true;
										}
									}
									//myFactory.alert("","银行卡信息填入成功","info");
									if(!flag){
										//没有扫描识别到银行名称，则通过配置名称进行匹配
										var bankName=myFactory.bankNameMatching(cardInsName);
										for(var i=0 ; i<$scope.banks.length ; i++){
											if($scope.banks[i].name.indexOf(bankName)>=0){
												$scope.bankSelect = $scope.banks[i].code;
												$("#bankSelect").val($scope.banks[i].code);
												$("#bankInput").val($scope.banks[i].name);
												/**
												 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 start
												 */
												showDialog2($scope.banks[i].code);
												if (isContain){
													showDialog($scope.banks[i].name)
												}
												sigleLimitAmount=$scope.banks[i].sigleLimitAmount;//单日限额
										        dayLimitAmount=$scope.banks[i].dayLimitAmount;//日累计限额
										        monthLimitAmount=$scope.banks[i].monthLimitAmount;//月累计限额
										        dueDate=$scope.banks[i].dueDate;//委托日期
												/**
												 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 end
												 */
											}
										}
										myFactory.alert("","银行卡信息填入成功","info");
									}else{
										myFactory.alert("","银行卡信息填入成功","info");
									}
									/*********************************待开发逻辑代码区域end**********************************/
								}
							}else{
								//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
								$scope.bigPic = result.data.bigPic;
								//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
								cordova.sino.confirmBankCardInfo(function(result){
									if(result.success){
										if(result.data.ok){
											/*********************************待开发逻辑代码区域begin**********************************/
											var cardNumber=result.data.CardNumber;//卡号
											var cardInsName=result.data.CardInsName;//领取银行
											var bankCardType=result.data.BankCardType;//银行卡类型
											//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
											if ( bankCardType.indexOf('贷')>=0 ){
												myFactory.alert("","信用卡账户不允许授权，请选择储蓄卡","info");
												return;
											}
											//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
											//alert(CardNumber+","+CardInsName+","+BankCardType);
											//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
											$scope.bankCardNum = cardNumber;
											//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
											cardNumber = cardNumber.replace(/ /g,"");
											$("#bankacctkeyForIntime").val(cardNumber);
											//自动填充开户银行
											var flag = false;
											for(var i=0 ; i<$scope.banks.length ; i++){
												if($scope.banks[i].name.indexOf(cardInsName)>=0){
													$scope.bankSelect = $scope.banks[i].code;
													$("#bankSelect").val($scope.banks[i].code);
													$("#bankInput").val($scope.banks[i].name);
													/**
													 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 start
													 */
													showDialog2($scope.banks[i].code);
													if (isContain){
														showDialog($scope.banks[i].name)
													}
													sigleLimitAmount=$scope.banks[i].sigleLimitAmount;//单日限额
											        dayLimitAmount=$scope.banks[i].dayLimitAmount;//日累计限额
											        monthLimitAmount=$scope.banks[i].monthLimitAmount;//月累计限额
											        dueDate=$scope.banks[i].dueDate;//委托日期
													/**
													 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 end
													 */
													flag = true;
												}
											}
											//myFactory.alert("","银行卡信息填入成功","info");
											if(!flag){
												//没有扫描识别到银行名称，则通过配置名称进行匹配
												var bankName=myFactory.bankNameMatching(cardInsName);
												for(var i=0 ; i<$scope.banks.length ; i++){
													if($scope.banks[i].name.indexOf(bankName)>=0){
														$scope.bankSelect = $scope.banks[i].code;
														$("#bankSelect").val($scope.banks[i].code);
														$("#bankInput").val($scope.banks[i].name);
														/**
														 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 start
														 */
														showDialog2($scope.banks[i].code);
														if (isContain){
															showDialog($scope.banks[i].name)
														}
														sigleLimitAmount=$scope.banks[i].sigleLimitAmount;//单日限额
												        dayLimitAmount=$scope.banks[i].dayLimitAmount;//日累计限额
												        monthLimitAmount=$scope.banks[i].monthLimitAmount;//月累计限额
												        dueDate=$scope.banks[i].dueDate;//委托日期
														/**
														 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） add by csf 20180926 end
														 */
													}
												}
												myFactory.alert("","银行卡信息填入成功","info");
											}else{
												myFactory.alert("","银行卡信息填入成功","info");
											}
											/*********************************待开发逻辑代码区域end**********************************/
										}
									}else{
										myFactory.alert('','扫描银行卡信息失败:'+result.data.errormsg,'info');
									}
								},result.data)
							}
						}
					}else{
						//sino.alert("扫描银行卡信息失败:"+result.data.errormsg);
						myFactory.alert('','扫描银行卡信息失败:'+result.data.errormsg,'info');
					}
				});

				//PC端开发测试用
//				var result = {
//					data : {
//						CardNumber:"6216678911114523785",
//						CardInsName:"农业银行",
//						BankCardType:"借记卡",
//						ok:true
//					}
//				};
//				if(result.data.ok){
//
//					/*********************************待开发逻辑代码区域begin**********************************/
//					var cardNumber=result.data.CardNumber;//卡号
//					var cardInsName=result.data.CardInsName;//领取银行
//					var bankCardType=result.data.BankCardType;//银行卡类型
//					//alert(CardNumber+","+CardInsName+","+BankCardType);
//				    cardNumber = cardNumber.replace(/ /g,"");
//			     	$("#bankacctkeyForIntime").val(cardNumber);
//					//自动填充开户银行
//					//var flag = false;
//					for(var i=0 ; i<$scope.banks.length ; i++){
//						if($scope.banks[i].name.indexOf(cardInsName)>=0){
//							$scope.bankSelect = $scope.banks[i].code;
//							$("#bankSelect").val($scope.banks[i].code);
//							$("#bankInput").val($scope.banks[i].name);
//							//flag = true;
//						}
//					}
//					myFactory.alert("","银行卡信息填入成功","info");
//					//if(!flag){
//					//myFactory.alert("","部分数据已自动填入，但查找不到领取银行，请手动选择领取银行与开户城市","info");
//					//}else{
//					//myFactory.alert("","部分数据已自动填入，请手动选择开户城市","info");
//					//}
//					/*********************************待开发逻辑代码区域end**********************************/
//				}

			}//扫描银行卡信息函数END
			//新增实时收付费客户须知 add by csf 2019-1-3 start
			//页面同意阅读协议复选框部分
			$scope.changeReadFlag = function(){
				$scope.readFlag = !$scope.readFlag;
			}
			//客户须知弹窗
			$scope.tipOpen = function(){
				modal('open','tip_model','overwindowOnChargeRefund');
			}
			$scope.closeTip = function(){
				modal('close','tip_model','overwindowOnChargeRefund');
			}
			//新增实时收付费客户须知 add by csf 2019-1-3 end
			
			/**
			 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）
			 * 新增签约接口的逻辑 add by csf 20180926 start
			 */ 
            	$scope.load=function(){
            		myFactory.loadingShow();
            		var timestamp=myFactory.getTimetamp();
    				var sfis= "chdrnum-chdrcoy-token-timestamp";
    				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
    				var sign = myFactory.hex(signStr);
    				//初始化时候查询保单详情
    				$http({
    					method: 'GET',
    					url: app.domain + 'query/restFindPolicyDetail.action',
    					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
    				}).then(function successCallback(response) {
    					if (response.data.success) {
    						policyData = response.data.data;
    						$scope.policyData = policyData;
    						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
    						cntbranch = $scope.policyData.chdrcoy+ $scope.policyData.cntbranch;
    						if (isContain){
    							//加载缓存中存在的所有银行信息，重组银行列表显示
    							myFactory.banklimit(function successCallback(response) {
    								var errCode = response.data.errCode;
    								bankinfomations = response.data.banks;
    								console.log(bankinfomations);
    								if (errCode != '' ){
    									  myFactory.alert("","当前系统繁忙，请稍后重试","info");
    				                	  myFactory.loadingHide();
    									  return;
    								}else if (errCode == '' && bankinfomations.length == 0 ){
    				                	  myFactory.alert("","当前系统繁忙，请稍后重试","info");
    				                	  myFactory.loadingHide();
    									  return;
    				                 } 
    										matchBankInfo();
    										 $scope.banks = pclistBack;
    										myFactory.loadingHide();
    							},function error(){
    								myFactory.alert("","当前系统繁忙，请稍后重试","info");
    								myFactory.loadingHide();
    								  return;
    							});
    						} 
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200508 start
                        else {
                            myFactory.loadingHide();
                        }
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200508 end
                    }
                }, function errorCallback(response) {
                    myFactory.alert("", "初始化查询订单详情失败!", "info");
                });
            }

            function bankSuccess(response) {
                var resCode = response.data.returnCode;
                //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_条件判断 by  CYQ  20190912 start
                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
                //if (resCode == '0' && (bankCode == '01' || bankCode == '71')) {
                if (resCode == '0') {
                /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
                    //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
	                	//S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_条件判断 by  CYQ  20190912 end
	                	contract();
	                }else{
	                	nextOnStep(accountNo);
	                }
	            }
	            function bankError(response){   	
	            	   myFactory.alert("","获取签约开关异常，请稍后重试","info");
	                   myFactory.loadingHide();
	            	   return;
	           }
	            /*add S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）--增加功能开关  by jiyongchang 20181211 end */ 
	            function showDialog(name){
	         		if(name.indexOf("签约")>=0 ){
						$('#showContractCase').show();
					}else {
						$('#showContractCase').hide();
					}
	         	}
	            function showDialog2(bankCode){
	            	 $scope.$apply(function () {
	            	for (var i = 0 ;i < pclistBack.length ; i ++ ){
						if ( pclistBack[i].code == bankCode ){
                            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 start
                            if ((pclistBack[i].limit != '' && pclistBack[i].limit > 0) && pclistBack[i].limit != '999999999' && bankCode != '04') { //有限额
                                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 end
								$scope.Bankaccount.counts = pclistBack[i].limit;
								$('#showbankCause').show();
							} else{
								$('#showbankCause').hide();
							}
						}
						}
	            	 });
	            }
	            function contract(){
                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 start
                //S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231127 start
                myFactory.goContract(accountNo, accountName, accountType, bankCode, phoneNum, code, signMode, '0', cntbranch, intimeData.charge.receiptAmount, idType, id,
                    vailddate, cvv2, sigleLimitAmount, dayLimitAmount, monthLimitAmount, dueDate, successCall, errorCall,
                    /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
                    //chdrnum01, itemId, paymentTimes, paymentDeadline, '0');
                    chdrnum01, itemId, paymentTimes, paymentDeadline, '0','','','','','','');
                    /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
                //S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231127 end
                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200220 end
	            }

                //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 start
                //点击确认关闭并触发校验方法
                $scope.citicTipClose = function(){
                    modal('close','zhongxinModelOnChargeIntime','overwindowOnChargeIntime','zhongxinCloseX');
                    nextOnStep(accountNo);
                };
                //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 end

            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
            $scope.ccbTipClose = function() {
                modal('close', 'ccbModelOnChargeIntime', 'overwindowOnChargeIntime');
                nextOnStep(accountNo);
            };
            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
          //S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start
            $scope.abcTipClose = function() {
                modal('close', 'abcModelOnChargeIntime', 'overwindowOnChargeIntime');
                nextOnStep(accountNo);
            };
            //S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end 

            //查询签约接口成功回调
            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
            var resCode;
            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
            function successCall(response) {
                myFactory.loadingHide();
                //查询是否签约的，未签约需要跳转到签约界面，并且传入相应参数
                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                resCode = response.data.resultCode;
                agreePayCompanyCode = response.data.paymentChannel;

                var billfreq; //缴费方式
                var nextamount = $scope.policy.nextamount01; //续期保费
                var paymentPeriodInfo = response.data.paymentPeriodInfo;
                if ('1' == paymentPeriodInfo.state) {
                    paymentTimes = paymentPeriodInfo.insPrem_PyF_Prd_Num; //缴费次数
                    paymentDeadline = paymentPeriodInfo.pyF_CODt; //缴费截止日
                    limitPer = paymentPeriodInfo.per_Amt_UpLm_Val; //单笔金额上限值
                    billfreq = paymentPeriodInfo.billfreq; //缴费方式  00、趸缴；01、年缴；02、半年缴；04、季缴；12、月缴 
                }

                //如果变更缴别，需要用变更后的缴别判断
                for (var i = 0; i < $scope.itemList.length; i++) {
                    if ($scope.itemList[i].itemId == '04') {
                        billfreq = $scope.itemList[i].billFreq;
                        nextamount = $scope.itemList[i].itemCalculate.newprem;
                        paymentTimes = myFactory.getInsPremPyfPrdNum(paymentTimes, paymentPeriodInfo.billfreq, $scope.itemList[i].billFreq);
                        break;
                    }
                }

                paymentDeadline = myFactory.getPaymentDeadline(paymentDeadline, billfreq);
                console.log("缴费方式:" + billfreq + ",缴费截止日" + paymentDeadline);

                var signFlag = false;
                var signData = response.data.signData;
                var receiptAmount = intimeData.charge.receiptAmount; //本次变更应缴金额
                var nextamount = '00' == billfreq ? '0' : nextamount; //续期保费
                maxMoney = myFactory.getMaxMoney(receiptAmount, nextamount, limitPer);
                var maxSignMoney = myFactory.getSignMoney(maxMoney);
                currentAmount = maxMoney;
                //如果变更缴别，单笔授权金额的最低限制，应为“变更后每期保费与本次变更应缴保费对比，取较大值”
                /*for (var i = 0; i < $scope.itemList.length; i++) {
                    if ($scope.itemList[i].itemId == '04') {
                        currentAmount = myFactory.getMaxMoney(fmtFactFeeTotal, nextamount, 0);
                    }
                }*/

                //如账号为已签约，如变更后的金额大于原授权金额，则要进入签约页面，允许修改授权金额；
                if ((resCode === 'R01' || resCode === 'R06') && bankCode == '04') {
                    //如账号为已签约，如变更后的缴费期数大于原授权次数、如变更后的金额大于原授权金额、如缴费方式为趸交，则要进入签约页面
                    //本次变更金额和P086返回的金额取较大值 * 1.2倍向上取整
                    if (parseInt(paymentTimes) > parseInt(signData.insPremPyfPrdNum) || parseFloat(maxSignMoney) > parseFloat(signData.sigleLimitAmount) ||
                        '00' == billfreq || myFactory.comparePayDate(paymentDeadline, signData.pyfCodt)) {
                        signFlag = true;
                        sigleLimitAmount = myFactory.getMaxMoney(maxSignMoney, maxSignMoney, signData.sigleLimitAmount);
                        paymentTimes = myFactory.getMaxInsPremPyfPrdNum(paymentTimes, signData.insPremPyfPrdNum);
                        paymentDeadline = myFactory.comparePayDate(paymentDeadline, signData.pyfCodt) ? paymentDeadline : signData.pyfCodt;
                    }
                } else if (resCode === 'R07') {
                    signFlag = true;
                    if (bankCode == '04') {
                        sigleLimitAmount = maxSignMoney;
                    }
                }

                if (!signFlag && (resCode === 'R05' || resCode === 'R06')) { //直连银行，无需签约 || 已签约
                    //当返回正常时，判断金额是否大于了银行限额
                    //	                	var isLimit = checkbanklimit();
                    //	                	if (isLimit){
                    //	                		myFactory.alert("","缴费金额超出银行转账限额，请您选择其它银行账户","info");
                    //	    					_checkFlag = false;
                    //	    					$scope.data.timeCon = "获取手机验证码";
                    //	    					$scope.textFlag = true;
                    //	    					$interval.cancel($scope.data.time1);//立即终止倒计时,避免出现滚动条转动的时候已经到时间临界点
                    //	    					timeOut="Y";//手动让当前验证码超时，让用户重新获取一次验证码
                    //	    					return;
                    //	                	}
                    //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 start
                    //var signData = response.data.signData;
                    //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                    var isDoSignature = signData.isDoSignature; //签名标志

                    if (resCode === 'R06' && isDoSignature == 'N') {
                        //合同文件初始化
                        var nowDate = new Date();
                        var nowYear = nowDate.getFullYear(); //当前年
                        var nowMonth = nowDate.getMonth() + 1; //当前月
                        nowMonth = nowMonth < 10 ? '0' + nowMonth : nowMonth;
                        var nowDay = nowDate.getDate() < 10 ? '0' + nowDate.getDate() : nowDate.getDate(); //当前日
                        var nowHour = nowDate.getHours() < 10 ? '0' + nowDate.getHours() : nowDate.getHours(); //当前时
                        var nowSeonds = nowDate.getMinutes() < 10 ? '0' + nowDate.getMinutes() : nowDate.getMinutes(); //当前分
                        var nowMilliseconds = nowDate.getSeconds() < 10 ? '0' + nowDate.getSeconds() : nowDate.getSeconds(); //当前秒
                        var deadlineStartTime = nowYear + '-' + nowMonth + '-' + nowDate.getDate(); //授权期限
                        var deadlineEndTime = '2099-12-31'; //授权期限
                        
                        /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010329 start*/
                        var signSuccessTime = signData.signSuccessTime;//签约成功时间(YYYY-MM-DD hh:ss:mm)
                        var signYear = signSuccessTime.substring(0,4);
                        var signMonth = signSuccessTime.substring(5,7);
                        var signDay = signSuccessTime.substring(8,10);
                        /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010329 end*/

                        var openBankName = bankNames; //开户行
                        if (bankNames.indexOf('(') > 0) {
                            openBankName = bankNames.substring(0, bankNames.indexOf("("));
                        }

                        var birthday = policyData.rnBirthday + "";
                        var tempdate = birthday.substr(0, 4) + "-" + birthday.substr(4, 2) + "-" + birthday.substr(6, 2);
                        var age = getAge(tempdate);
                        var bankAccountName = signData.accountName;
                        if (age < 18) {
                            bankAccountName = policyData.surname + "";
                        }

                        for (var i = 0; i < $scope.idTypeLF.length; i++) {
                            if ($scope.idTypeLF[i].contractVal === signData.cardIdType) {
                                idTypeName = $scope.idTypeLF[i].text; //证件类型名称
                                break;
                            }
                        }

                        for (var i = 0; i < bankinfomations.length; i++) {
                            //判断当机构和银行编码一致时使用，最佳
                            if (signData.bankCode == bankinfomations[i].reqBankCode) {
                                openBankName = bankinfomations[i].bankName;
                                break;
                            }
                        }

                            $scope.contractZxInfo={
                            		accountName:signData.accountName,//账户名
                            		accountNum:signData.accountNo,//账户号
                            		idType:signData.cardIdType,//证件类型
                            		idNum:signData.cardId,//证件号码*/
                            		openBankName:openBankName,//开户行
                            		idTypeName:idTypeName,//证件类型名称
                            		sigleLimitAmount:signData.sigleLimitAmount,//付款单笔限额
                            		dayLimitAmount:signData.dayLimitAmount,//付款日累计限额
                            		monthLimitAmount:signData.monthLimitAmount, //付款月累计限额
                            		deadlineStartTime:deadlineStartTime,//授权期限
                            		deadlineEndTime:deadlineEndTime,//授权期限
                            		nowYear:nowYear,//当前年
                            		nowMonth:nowMonth,//当前月
                            		nowDay:nowDay,//当前日
                            		nowHour:nowHour,//当前时
                            		nowSeonds:nowSeonds,//当前分
                            		nowMilliseconds:nowMilliseconds, //当前秒
                            /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010329 start*/
                            signYear : signYear,
                            signMonth : signMonth,
                            signDay : signDay,
                            /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010329 end*/
                            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                            bankAccountName: bankAccountName, //授权人签名
                            resultSign: resCode, //签约查询返回码
                            authorizedAmt: signData.signTotalMoney, //授权金额
                            paymentDeadline: signData.pyfCodt, //缴费截止日期
                            paymentTimes: signData.insPremPyfPrdNum, //缴费次数
                            //limitPer:signData.signTotalMoney//每期扣款限额
                            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                        };
                        //跳转
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                        if (signData.bankCode == '01' || signData.bankCode == '71') {
                            modal('open', 'zhongxinModelOnChargeIntime', 'overwindowOnChargeIntime', 'zhongxinCloseX');
                        } else if (signData.bankCode == '04') {
                            modal('open', 'ccbModelOnChargeIntime', 'overwindowOnChargeIntime');
                        }
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                        /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
                        /*S2022032221693-农业银行客户签约补充需求 add by huanghaokun 20220506 start*/
                        /*else if (signData.bankCode == '05'){
                        	modal('open', 'abcModelOnChargeIntime', 'overwindowOnChargeIntime');
                        }*/
                        /*S2022032221693-农业银行客户签约补充需求 add by huanghaokun 20220506 end*/
                        else{
                        	nextOnStep(accountNo);
                        }
                        /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
                    } else {
                        //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 end
                        nextOnStep(accountNo);
                        //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 start
                    }
                    //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 end
                    //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                } else if (signFlag) {
                    //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                    //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 start
                    /*myFactory.alert("提示", "缴费银行未授权签约，请客户先在银行或我司官微办理授权签约手续后，再受理本次申请；或选择其它缴费银行。谢谢！","info");
	                	return;*/
						
	                    //要签约，跳转到签约界面
	                	modal('open','contract_model_info','overwindowOnChargeRefund');
            //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190912 end
	                }else{
	                	 $scope.startItervalForIntime();
	                	 if ( resCode === 'R09'){
	                		 _checkFlag = false;
	                	 }
	                     myFactory.alert("",response.data.resultMsg,"info");
	                     return;
	                }
	            }
	            $scope.toContract = function(clickType){
	             	_checkFlag = false;
	            	if(clickType =='Y'){
                  //S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 start
                	//被保险人为未成年人,授权人签名取投保人的名称
                    var birthday = policyData.rnBirthday + "";
                    var tempdate = birthday.substr(0, 4) + "-" + birthday.substr(4, 2) + "-" + birthday.substr(6, 2);
                    var age = getAge(tempdate);
                    var bankAccountName = accountName;
                    if (age < 18) {
                        bankAccountName = policyData.surname + "";
                    }
                	//S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 end
	            		isContract = true;
	            		//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
						var bankCardItems = {
									bankAccNum:accountNo
						}
						if($scope.bankCardNum == accountNo){
							bankCardItems['bigPic'] = $scope.bigPic;
						}
							 var timestamp = myFactory.getTimetamp();
			                 var sfis = "token-timestamp";
			                 var signStr = "token=" + token + "&timestamp=" + timestamp;//encodeURI(name)
			                 var sign = myFactory.hex(signStr);
							$http({
								method: 'POST',
								url: app.domain + 'img/saveBankCardCache.action',
								data:{paramsMap:bankCardItems,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
							}).then(function successCallback(response) {
								if (response.data.success) {
									console.log("saveBankCardCache ok");
								}
							}, function errorCallback(response) {
								console.log("saveIdCardCache error");
							});
							
						//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
						
	    				//数据包装
	    				var pageData2 = {
//	    						"accountFlag":$("#accountFlag").val().trim(),
	    						"accountType":$("#accountTypeSelect option:selected").val().trim(),
	    						"bankacctkey":accountNo,
//	    						"bankacctkey1":$("#bankacctkey1").val().trim(),
//	    						"bankacctkey3":$("#bankacctkey3").val().trim(),
	    						"bankacctkeyCon":accountNo,
	    						"bankcode":$("#bankSelect option:selected").val().trim(),
//	    						"bankcode1":$("#bankcode1").val().trim(),
//	    						"bankcode3":$("#bankcode3").val().trim(),
//	    						"bankdesc":$("#newBankSelect option:selected").text().trim(),
//	    						"bankdesc1":$("#bankdesc1").val().trim(),
//	    						"bankdesc3":$("#bankdesc3").val().trim(),
//	    						"beneClntNum":beneClntNum,
	    						"chargeType":"1",
	    						//"city":"5810",//页面上隐藏了选择城市部分，然后采用默认的广州（代码5810）
	    						"city":"",//页面上隐藏了选择城市部分，然后采用默认的广州（代码5810）
//	    						"city1":$("#city1").val().trim(),
//	    						"city3":$("#city3").val().trim(),
//	    						"citydesc":$("#newCity").val().trim(),
//	    						"citydesc1":$("#citydesc1").val().trim(),
//	    						"citydesc3":$("#citydesc3").val().trim(),
//	    						"itemIds":itemIds,
	    						"paynme":$("#paynmeForIntime").val().trim(),
//	    						"paynme1":$("#paynme1").val().trim(),
//	    						"paynme3":$("#paynme3").val().trim(),
	    						"paynmeFlag":$("#paynmeFlagForIntime").val().trim(),
//	    						"paynum":$("#paynum").val().trim(),
//	    						"paynum1":$("#paynum1").val().trim(),
//	    						"paynum3":$("#paynum3").val().trim(),
	    						"receiptAmount":intimeData.charge.receiptAmount,
//	    						"type":Type
                        //S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 start
                        "mobile":intimeData.telNo,
                        //S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 end
	    				}
	            		var items = {};
	    			     	items['chdrnum01'] = chdrnum01;
	                        items['chdrcoy'] = chdrcoy;
	                        items['pageData2'] = pageData2;
	                    var contractItem={
	                    		itemId:itemId,
	                    		userName:accountName,
	                    		accountType:accountType,
	                    		code:code,
	                    		signMode:signMode,
	                    		isReal:'0',
	                    		branch:cntbranch,
	                    		idType:idType,
	                    		idNum:id,
	                    		accountNo:accountNo,
	                    		phoneNo:phoneNum,
	                    		BankName:bankNames,
	                    		BankCode:bankCode,
	                    		BankList:$scope.bankList,
	                    		nextAction:null,
	                    		items:items,
	                    		flag:'3',
	                    		agreePayCompanyCode:agreePayCompanyCode,
                            	sigleLimitAmount:sigleLimitAmount,//单日限额
                        		dayLimitAmount:dayLimitAmount,//日累计限额
                        		monthLimitAmount:monthLimitAmount,//月累计限额
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                        dueDate: dueDate, //委托日期
                        resultSign: resCode, //签约查询返回码
                        authorizedAmt: authorizedAmt, //授权金额
                        paymentDeadline: paymentDeadline, //缴费截止日期
                        paymentTimes: paymentTimes, //缴费次数
                        currentAmount: currentAmount, //当前期缴保费
                        //limitPer:limitPer//每期扣款限额
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                        //S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 start
                		bankAccountName:bankAccountName,//授权人签名
                		//S2021020516689银行签约授权功能需求  add by huanghaokun 20210324 end
                		/*S2023011824901-官微授权银行页面超限额无拦截、非签约银行进入签约页面问题 add by huanghk 20230216 start*/
                        signMoney: intimeData.charge.receiptAmount,
                        /*S2023011824901-官微授权银行页面超限额无拦截、非签约银行进入签约页面问题 add by huanghk 20230216 end*/

                    };
                  //S2021020516689银行签约授权功能需求  add by mqz 20210302 start
                    if( bankCode == '01' || bankCode == '71' || bankCode == '04') {
                    	 $state.go('contract',{contractItem:contractItem});
                    }else{
                         $state.go('contract_other',{contractItem:contractItem});
                    }
                  //S2021020516689银行签约授权功能需求  add by mqz 20210302 end
                } else {
                    isContract = false;
                }
                modal('close', 'contract_model_info', 'overwindowOnChargeRefund');
            }

            //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190910 start
            /*根据出生日期算出年龄*/
            function getAge(strBirthday) {
                var returnAge;
                var strBirthdayArr = strBirthday.split("-");
                var birthYear = strBirthdayArr[0];
                var birthMonth = strBirthdayArr[1];
                var birthDay = strBirthdayArr[2];

                d = new Date();
                var nowYear = d.getFullYear();
                var nowMonth = d.getMonth() + 1;
                var nowDay = d.getDate();

                if (nowYear == birthYear) {
                    returnAge = 0; //同年 则为0岁  
                } else {
                    var ageDiff = nowYear - birthYear; //年之差  
                    if (ageDiff > 0) {
                        if (nowMonth == birthMonth) {
                            var dayDiff = nowDay - birthDay; //日之差  
                            if (dayDiff < 0) {
                                returnAge = ageDiff - 1;
                            } else {
                                returnAge = ageDiff;
                            }
                        } else {
                            var monthDiff = nowMonth - birthMonth; //月之差  
                            if (monthDiff < 0) {
                                returnAge = ageDiff - 1;
                            } else {
                                returnAge = ageDiff;
                            }
                        }
                    } else {
                        returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天  
                    }
                }
                return returnAge; //返回周岁年龄  
            }
            //S2018062604412网联政策630实施相关系统功能改造需求(中信银行签约需求)_授权书赋值 by  CYQ  20190910 end

	            //查询签约接口失败回调
	            function errorCall() {
	                myFactory.loadingHide();
	                myFactory.alert("","查询签约失败，请稍后重试","info");
	                return;
	            }
	            
	            //查询银行限额
//	            function checkbanklimit(){
//					var isBankLimit = false;
//		                	 console.log("当前保单所属的机构号："+$scope.policyData.cntbranch);
//		                	 for ( var i = 0 ; i < pclistBack.length ; i ++ ){
//		                		 var bankinfo = pclistBack[i];
//		                		 if (bankCode == bankinfo.code ){
//		                			 //当限额为空	
//		                			 if (bankinfo.limit != '' || bankinfo.limit > 0){//有限额
//				                		  if ( Number(intimeData.charge.receiptAmount) > Number(bankinfo.limit) ){//需要支付的金额
//			                				 isBankLimit = true;
//			                				 break;
//				                		  }
//			                		 }
//		                		 }
//		                	 }
//
//		               return isBankLimit;
//		            }
	          //匹配银行是否签约以及银行限额信息
	         	function matchBankInfo(){
					for(var j=0;j < $scope.banks.length ; j ++){ 
						 var item = $scope.banks[j];
						 var isMate = true;
						 var a ={};
						 var temp=null;
						 for ( var i = 0 ; i < bankinfomations.length ; i ++ ){
							 //判断当机构和银行编码一致时使用，最佳
							 if (item.code == bankinfomations[i].reqBankCode && cntbranch == bankinfomations[i].branch ){
                            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                            if (bankinfomations[i].onlineNeedSign == 'Y' && item.code != '04') {
                                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
									 	a.name=item.name + "(需要签约)";
										a.code=item.code;
										a.limit = bankinfomations[i].limitAmount
								 } else {
									   	a.name=item.name ;
										a.code=item.code;
										a.limit =  bankinfomations[i].limitAmount
								 }
								 a.code=item.code;
								 a.limit = bankinfomations[i].limitAmount
								 a.sigleLimitAmount = bankinfomations[i].sigleLimitAmount;//付款单笔限额
								 a.dayLimitAmount = bankinfomations[i].dayLimitAmount;//付款日累计限额
								 a.monthLimitAmount = bankinfomations[i].monthLimitAmount;//付款月累计限额
								 a.dueDate = bankinfomations[i].dueDate;//委托日期
								 isMate = true;
									break;
							 } else {
								 isMate = false;
							 }
							 if (item.code == bankinfomations[i].reqBankCode && bankinfomations[i].branch == 'ALL'){
								 temp = bankinfomations[i];
							 }
						 }
						 if (!isMate && temp !=null){
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                        if (temp.onlineNeedSign == 'Y' && temp.reqBankCode != '04') {
                            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
								 	a.name=item.name + "(需要签约)";
							 } else {
								   	a.name=item.name ;
							 }
							 a.code=item.code;
							 a.limit =  temp.limitAmount
							 a.sigleLimitAmount = temp.sigleLimitAmount;//付款单笔限额
							 a.dayLimitAmount = temp.dayLimitAmount;//付款日累计限额
							 a.monthLimitAmount = temp.monthLimitAmount;//付款月累计限额
							 a.dueDate = temp.dueDate;//委托日期
								isMate = true;		
						 }
						 if (!isMate){//没有匹配到银行信息，则默认不需要签约
							 a.name=item.name;
							 a.code=item.code;
							 a.limit =  "";//默认没有限额
							 a.sigleLimitAmount = "500000";//付款单笔限额
							 a.dayLimitAmount = "500000";//付款日累计限额
							 a.monthLimitAmount = "500000";//付款月累计限额
							 a.dueDate = "20991231";//委托日期
						 }
						 pclistBack.push(a);
				}
	         	}
	        	/**
				 * S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）
				 * 新增签约接口的逻辑 add by csf 20180926 end
				 * 
				 */
		}]);       
	
		//指针弹窗
		app.directive('infoid',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/content_base_info.html'+app.clearCache,
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('指令完成');
				}
			}
		});
})(app)